<template>
	<AdminLayout activeKey="task-audit" :breadcrumbs="['首页','任务发布审核']" tabTitle="任务发布审核">
		<view class="page">
			<view class="section-header">
				<text class="section-title">任务发布审核</text>
				<text class="section-desc">审核用户发布的任务，管理任务状态</text>
			</view>
			
			<!-- 筛选工具栏 -->
			<view class="filter-toolbar">
				<input 
					class="search-input" 
					v-model="taskFilters.keyword" 
					placeholder="搜索任务标题或描述" 
					@input="onSearchInput"
					@confirm="onSearchConfirm"
				/>
				<picker mode="selector" :range="taskTypeOptions" @change="onTaskTypeChange">
					<view class="picker-btn">类型：{{ taskFilters.type || '全部' }}</view>
				</picker>
				<picker mode="selector" :range="taskStatusOptions" @change="onTaskStatusChange">
					<view class="picker-btn">状态：{{ taskFilters.status || '全部' }}</view>
				</picker>
				<picker mode="selector" :range="auditStatusOptions" @change="onAuditStatusChange">
					<view class="picker-btn">审核：{{ taskFilters.auditStatus || '全部' }}</view>
				</picker>
				<button class="filter-btn" @click="loadTasks">刷新</button>
			</view>

			<!-- 任务列表 -->
			<scroll-view scroll-y class="task-list">
				<view v-for="task in taskList" :key="task._id" class="task-item" 
				      :class="{
				        pending: task.audit_status === 'pending',
				        approved: task.audit_status === 'approved',
				        rejected: task.audit_status === 'rejected',
				        hidden: !task.is_visible
				      }">
					<view class="task-header">
						<view class="task-meta">
							<text class="task-type">{{ getTaskTypeText(task.type) }}</text>
							<text class="task-reward">¥{{ task.reward }}</text>
							<text class="task-status" :class="task.status">{{ getTaskStatusText(task.status) }}</text>
							<text class="audit-status" :class="task.audit_status || 'pending'">{{ getAuditStatusText(task.audit_status) }}</text>
						</view>
						<text class="publish-time">{{ formatTime(task.publish_time) }}</text>
					</view>
					
					<view class="task-content">
						<text class="task-title">{{ task.title }}</text>
						<text class="task-desc">{{ task.description }}</text>
						<view class="publisher-info">
							<text>发布者：{{ task.publisher?.nickname || task.publisher_name || '未知用户' }}</text>
						</view>
					</view>

					<view class="task-actions">
						<button size="mini" @click="viewTaskDetail(task)">查看详情</button>
						
						<!-- 审核按钮组 -->
						<view v-if="getAvailableAuditActions(task).length > 0" class="audit-actions">
							<button 
								v-for="action in getAvailableAuditActions(task)" 
								:key="action.key"
								class="audit-btn"
								:class="action.type"
								@click="auditTask(task, action.key)"
							>
								<text class="audit-icon">{{ action.icon }}</text>
								<text>{{ action.text }}</text>
							</button>
						</view>
						
						<!-- 任务状态提示 -->
						<view v-if="task.status === 'cancelled' || task.status === 'completed'" 
						      class="task-status-tip" 
						      :class="{ 'cancelled': task.status === 'cancelled', 'completed': task.status === 'completed' }">
							<text>{{ task.status === 'cancelled' ? '已下架' : '已完成' }}</text>
						</view>
						
						<button size="mini" @click="editTask(task)">编辑</button>
						<button size="mini" type="warn" @click="toggleTaskVisibility(task)">
							{{ task.is_visible ? '隐藏' : '显示' }}
						</button>
						<button v-if="task.status !== 'cancelled'" size="mini" type="warn" @click="takeDownTask(task)">下架</button>
						<button size="mini" type="danger" @click="deleteTask(task)">删除</button>
					</view>
				</view>
			</scroll-view>
		</view>

		<!-- 任务详情弹窗 -->
		<view v-if="showDetailModal" class="modal-overlay detail-overlay" @click="closeDetailModal">
			<view class="modal-content detail-modal" @click.stop>
				<view class="modal-header">
					<text class="modal-title">任务详情</text>
					<text class="modal-close" @click="closeDetailModal">×</text>
				</view>
				
				<scroll-view scroll-y class="modal-body detail-body">
					<view class="detail-section">
						<view class="detail-title">{{ currentDetailTask.title }}</view>
						<view class="detail-meta">
							<view class="meta-row">
								<text class="meta-label">任务类型</text>
								<text class="meta-value type-tag">{{ getTaskTypeText(currentDetailTask.type) }}</text>
							</view>
							<view class="meta-row">
								<text class="meta-label">任务报酬</text>
								<text class="meta-value reward-value">¥{{ currentDetailTask.reward }}</text>
							</view>
							<view class="meta-row">
								<text class="meta-label">任务状态</text>
								<text class="meta-value status-tag" :class="currentDetailTask.status">{{ getTaskStatusText(currentDetailTask.status) }}</text>
							</view>
							<view class="meta-row">
								<text class="meta-label">审核状态</text>
								<text class="meta-value audit-tag" :class="currentDetailTask.audit_status || 'pending'">{{ getAuditStatusText(currentDetailTask.audit_status) }}</text>
							</view>
						</view>
					</view>
					
					<view class="detail-section">
						<view class="section-title">任务描述</view>
						<view class="section-content">{{ currentDetailTask.description || '暂无描述' }}</view>
					</view>
					
					<view class="detail-section" v-if="currentDetailTask.requirements">
						<view class="section-title">任务要求</view>
						<view class="section-content">{{ currentDetailTask.requirements }}</view>
					</view>
					
					<view class="detail-section">
						<view class="section-title">发布信息</view>
						<view class="publisher-card">
							<view class="publisher-row">
								<text class="publisher-label">发布者</text>
								<text class="publisher-name">{{ currentDetailTask.publisher?.nickname || currentDetailTask.publisher_name || '未知用户' }}</text>
							</view>
							<view class="publisher-row">
								<text class="publisher-label">发布时间</text>
								<text class="publisher-time">{{ formatTime(currentDetailTask.publish_time) }}</text>
							</view>
							<view class="publisher-row" v-if="currentDetailTask.deadline">
								<text class="publisher-label">截止时间</text>
								<text class="publisher-time">{{ formatTime(currentDetailTask.deadline) }}</text>
							</view>
						</view>
					</view>
					
					<!-- 接单人信息 - 进行中和已完成状态显示 -->
					<view class="detail-section" v-if="currentDetailTask.status === 'processing' || currentDetailTask.status === 'completed'">
						<view class="section-title">接单人信息</view>
						<view class="accepter-card" :class="{ completed: currentDetailTask.status === 'completed' }" v-if="getAccepterInfo(currentDetailTask)">
							<view class="accepter-row">
								<text class="accepter-label">接单人</text>
								<text class="accepter-name">{{ getAccepterInfo(currentDetailTask).nickname || '未知用户' }}</text>
							</view>
							<view class="accepter-row" v-if="getAccepterInfo(currentDetailTask).phone">
								<text class="accepter-label">联系电话</text>
								<text class="accepter-phone">{{ getAccepterInfo(currentDetailTask).phone }}</text>
							</view>
							<view class="accepter-row" v-if="getAccepterInfo(currentDetailTask).accept_time">
								<text class="accepter-label">接单时间</text>
								<text class="accepter-time">{{ formatTime(getAccepterInfo(currentDetailTask).accept_time) }}</text>
							</view>
							<view class="accepter-row" v-if="currentDetailTask.status === 'completed' && (getAccepterInfo(currentDetailTask).complete_time || currentDetailTask.complete_time)">
								<text class="accepter-label">完成时间</text>
								<text class="accepter-time">{{ formatTime(getAccepterInfo(currentDetailTask).complete_time || currentDetailTask.complete_time) }}</text>
							</view>
							<view class="accepter-row" v-if="getAccepterInfo(currentDetailTask).status">
								<text class="accepter-label">状态</text>
								<text class="accepter-status" :class="getAccepterInfo(currentDetailTask).status">{{ getAccepterStatusText(getAccepterInfo(currentDetailTask).status) }}</text>
							</view>
						</view>
						<view class="no-accepter-tip" v-else>
							<text class="tip-text">暂无接单人信息</text>
						</view>
					</view>
					
					<view class="detail-section" v-if="currentDetailTask.audit_time || currentDetailTask.reject_reason">
						<view class="section-title">审核信息</view>
						<view class="audit-card">
							<view class="audit-row" v-if="currentDetailTask.audit_time">
								<text class="audit-label">审核时间</text>
								<text class="audit-time">{{ formatTime(currentDetailTask.audit_time) }}</text>
							</view>
							<view class="audit-row" v-if="currentDetailTask.audit_admin">
								<text class="audit-label">审核管理员</text>
								<text class="audit-admin">{{ currentDetailTask.audit_admin }}</text>
							</view>
							<view class="audit-row" v-if="currentDetailTask.reject_reason">
								<text class="audit-label">拒绝原因</text>
								<text class="audit-reason">{{ currentDetailTask.reject_reason }}</text>
							</view>
						</view>
					</view>
				</scroll-view>
				
				<view class="modal-footer">
					<button class="modal-btn cancel-btn" @click="closeDetailModal">关闭</button>
				</view>
			</view>
		</view>

		<!-- 编辑任务弹窗 -->
		<view v-if="showEditModal" class="modal-overlay" @click="closeEditModal">
			<view class="modal-content" @click.stop>
				<view class="modal-header">
					<text class="modal-title">编辑任务</text>
					<text class="modal-close" @click="closeEditModal">×</text>
				</view>
				
				<scroll-view scroll-y class="modal-body">
					<view class="form-group">
						<text class="form-label">任务标题 *</text>
						<input class="form-input" v-model="editForm.title" placeholder="请输入任务标题" />
					</view>
					
					<view class="form-group">
						<text class="form-label">任务类型 *</text>
						<picker mode="selector" :range="taskTypeOptions.slice(1)" @change="onEditTaskTypeChange" class="picker-wrapper">
							<view class="form-picker">{{ getTaskTypeText(editForm.type) || '请选择任务类型' }}</view>
						</picker>
					</view>
					
					<view class="form-group">
						<text class="form-label">任务报酬 *</text>
						<input class="form-input" type="number" v-model="editForm.reward" placeholder="请输入任务报酬（元）" />
					</view>
					
					<view class="form-group">
						<text class="form-label">截止时间</text>
						<picker mode="datetime" @change="onDeadlineChange" class="picker-wrapper">
							<view class="form-picker">{{ formatDeadline(editForm.deadline) || '请选择截止时间' }}</view>
						</picker>
					</view>
					
					<view class="form-group">
						<text class="form-label">任务描述 *</text>
						<textarea class="form-textarea" v-model="editForm.description" placeholder="请输入任务描述" />
					</view>
					
					<view class="form-group">
						<text class="form-label">任务要求</text>
						<textarea class="form-textarea" v-model="editForm.requirements" placeholder="请输入任务要求（可选）" />
					</view>
				</scroll-view>
				
				<view class="modal-footer">
					<button class="modal-btn cancel-btn" @click="closeEditModal">取消</button>
					<button class="modal-btn confirm-btn" @click="saveTaskEdit">保存</button>
				</view>
			</view>
		</view>
	</AdminLayout>
</template>

<script>
import AdminLayout from '@/components/AdminLayout.vue'
const SENSITIVE = ['违法','敏感','诈骗','广告','性','黄','毒','赌']

export default {
	components: { AdminLayout },
	data() {
		return {
			// 任务相关
			taskList: [],
			allTaskList: [], // 存储所有任务数据，用于本地搜索
			taskFilters: {
				keyword: '',
				type: '',
				status: '',
				auditStatus: ''
			},
			taskTypeOptions: ['全部', '代购', '出物', '快递', '外卖', '其他'],
			taskStatusOptions: ['全部', '待接单', '进行中', '已完成', '已取消'],
			auditStatusOptions: ['全部', '待审核', '已通过', '已拒绝'],
			searchTimer: null, // 搜索防抖定时器
			showDetailModal: false, // 控制详情弹窗显示
			currentDetailTask: {}, // 当前查看详情的任务
			showEditModal: false, // 控制编辑弹窗显示
			currentEditTask: null, // 当前编辑的任务
			editForm: {
				title: '',
				description: '',
				type: '',
				reward: '',
				deadline: '',
				requirements: ''
			}
		}
	},

	mounted() {
		this.loadTasks()
	},

	methods: {
		// 时间格式化
		formatTime(v) {
			if (!v) return '--'
			const d = new Date(v)
			const p = n => String(n).padStart(2, '0')
			return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`
		},

		// 加载任务列表
		async loadTasks() {
			try {
				const { result } = await uniCloud.callFunction({
					name: 'getTaskList',
					data: {
						page: 1,
						pageSize: 50,
						type: this.taskFilters.type === '全部' ? '' : this.getTaskTypeKey(this.taskFilters.type),
						status: this.taskFilters.status === '全部' ? '' : this.getTaskStatusKey(this.taskFilters.status),
						audit_status: this.taskFilters.auditStatus === '全部' ? '' : this.getAuditStatusKey(this.taskFilters.auditStatus),
						keyword: this.taskFilters.keyword,
						isAdmin: true, // 管理员查询，可以看到所有任务
						showAll: true  // 显示所有任务包括不可见的
					}
				})
				
				if (result && result.code === 200 && result.data && result.data.length > 0) {
					// 使用真实数据，确保每个任务都有必要的字段
					this.taskList = result.data.map(task => ({
						...task,
						audit_status: task.audit_status || 'pending',
						publisher_name: task.publisher_name || task.user_name || '未知用户',
						// 确保保留publisher对象
						publisher: task.publisher || {
							nickname: task.publisher_name || task.user_name || '未知用户',
							avatar: task.publisher_avatar || ''
						},
						// 确保审核相关字段正确映射
						audit_time: task.audit_time,
						audit_admin: task.audit_admin,
						reject_reason: task.reject_reason || ''
					}))
					
					// 保存所有数据到allTaskList用于搜索
					this.allTaskList = [...this.taskList]
					
					// 应用当前筛选和搜索条件
					this.applyFilters()
					
					console.log('加载真实数据成功:', this.taskList)
					uni.showToast({ title: '加载数据成功', icon: 'success' })
				} else {
					throw new Error('无数据返回')
				}
			} catch (error) {
				console.error('加载任务列表失败:', error)
				// 云函数失败时使用模拟数据作为后备
				this.taskList = [
					{
						_id: '1',
						type: 'other',
						title: '积分测试',
						description: '',
						reward: 2,
						status: 'pending',
						publisher_name: '测试用户1',
						publish_time: Date.now(),
						audit_status: 'pending'
					},
					{
						_id: '2',
						type: 'express',
						title: '快递代取',
						description: '放楼下',
						reward: 13,
						status: 'processing',
						publisher_name: '张同学',
						publish_time: Date.now() - 3600000,
						audit_status: 'approved'
					},
					{
						_id: '3',
						type: 'other',
						title: '违规任务测试',
						description: '这是一个被拒绝的任务',
						reward: 10,
						status: 'cancelled',
						publisher_name: '李同学',
						publish_time: Date.now() - 7200000,
						audit_status: 'rejected'
					},
					{
						_id: '4',
						type: 'sell',
						title: '出九成新zyt的电脑',
						description: '女大自用九九新',
						reward: 10000,
						status: 'processing',
						publisher_name: '王同学',
						publish_time: Date.now() - 10800000,
						audit_status: 'approved'
					},
					{
						_id: '5',
						type: 'buy',
						title: '代购奶茶',
						description: '需要审核的任务',
						reward: 5,
						status: 'pending',
						publisher_name: '赵同学',
						publish_time: Date.now() - 1800000,
						audit_status: 'pending'
					},
					{
						_id: '6',
						type: 'other',
						title: '另一个被拒绝的任务',
						description: '内容不符合规范',
						reward: 8,
						status: 'cancelled',
						publisher_name: '钱同学',
						publish_time: Date.now() - 5400000,
						audit_status: 'rejected'
					},
					{
						_id: '7',
						type: 'takeout',
						title: '代取外卖',
						description: '帮忙取一份麦当劳外卖，楼下取餐',
						reward: 3,
						status: 'pending',
						publisher_name: '孙同学',
						publish_time: Date.now() - 900000,
						audit_status: 'pending'
					},
					{
						_id: '8',
						type: 'express',
						title: '快递代取任务（已完成）',
						description: '菜鸟驿站取快递，已成功完成',
						reward: 5,
						status: 'completed',
						publisher_name: '陈同学',
						publish_time: Date.now() - 86400000, // 1天前发布
						audit_status: 'approved'
					}
				]
				
				// 保存所有数据到allTaskList用于搜索
				this.allTaskList = [...this.taskList]
				
				// 应用当前筛选和搜索条件
				this.applyFilters()
				
				console.log('使用模拟数据:', this.taskList)
				uni.showToast({ title: '云函数失败，使用模拟数据', icon: 'none' })
			}
		},

		// 任务类型筛选
		onTaskTypeChange(e) {
			const index = Number(e.detail.value)
			this.taskFilters.type = this.taskTypeOptions[index]
			this.applyFilters()
		},

		// 任务状态筛选
		onTaskStatusChange(e) {
			const index = Number(e.detail.value)
			this.taskFilters.status = this.taskStatusOptions[index]
			this.applyFilters()
		},

		// 审核状态筛选
		onAuditStatusChange(e) {
			const index = Number(e.detail.value)
			this.taskFilters.auditStatus = this.auditStatusOptions[index]
			this.applyFilters()
		},

		// 搜索输入事件（实时搜索）
		onSearchInput(e) {
			// 清除之前的定时器
			if (this.searchTimer) {
				clearTimeout(this.searchTimer)
			}
			
			// 设置防抖，300ms后执行搜索
			this.searchTimer = setTimeout(() => {
				this.applyFilters()
			}, 300)
		},

		// 搜索确认事件
		onSearchConfirm() {
			// 清除定时器，立即执行搜索
			if (this.searchTimer) {
				clearTimeout(this.searchTimer)
			}
			this.applyFilters()
		},

		// 应用筛选和搜索条件
		applyFilters() {
			let filteredList = [...this.allTaskList]

			// 关键词搜索
			if (this.taskFilters.keyword && this.taskFilters.keyword.trim()) {
				const keyword = this.taskFilters.keyword.trim().toLowerCase()
				filteredList = filteredList.filter(task => {
					const title = (task.title || '').toLowerCase()
					const description = (task.description || '').toLowerCase()
					const publisherName = (task.publisher_name || task.publisher?.nickname || '').toLowerCase()
					
					return title.includes(keyword) || 
						   description.includes(keyword) || 
						   publisherName.includes(keyword)
				})
			}

			// 任务类型筛选
			if (this.taskFilters.type && this.taskFilters.type !== '全部') {
				const typeKey = this.getTaskTypeKey(this.taskFilters.type)
				filteredList = filteredList.filter(task => task.type === typeKey)
			}

			// 任务状态筛选
			if (this.taskFilters.status && this.taskFilters.status !== '全部') {
				const statusKey = this.getTaskStatusKey(this.taskFilters.status)
				filteredList = filteredList.filter(task => task.status === statusKey)
			}

			// 审核状态筛选
			if (this.taskFilters.auditStatus && this.taskFilters.auditStatus !== '全部') {
				const auditStatusKey = this.getAuditStatusKey(this.taskFilters.auditStatus)
				filteredList = filteredList.filter(task => (task.audit_status || 'pending') === auditStatusKey)
			}

			// 按优先级排序：需要审核的任务优先显示，已完成/取消的任务显示在最后
			filteredList.sort((a, b) => {
				const priorityA = this.getTaskPriority(a)
				const priorityB = this.getTaskPriority(b)
				
				// 如果优先级不同，按优先级排序（数字越小优先级越高）
				if (priorityA !== priorityB) {
					return priorityA - priorityB
				}
				
				// 如果优先级相同，按时间倒序排序（新的在前）
				const timeA = a.publish_time || 0
				const timeB = b.publish_time || 0
				return timeB - timeA
			})

			this.taskList = filteredList
		},

		// 查看任务详情
		async viewTaskDetail(task) {
			let taskWithDetails = { ...task }
			
			try {
				// 首先尝试获取详细的任务信息（包含接单人信息）
				const { result } = await uniCloud.callFunction({
					name: 'getTaskOrders',
					data: { 
						isAdmin: true,
						includeAll: true,
						page: 1,
						pageSize: 1,
						keyword: task.title // 通过标题搜索特定任务
					}
				})
				
				if (result && result.code === 200 && result.data && result.data.records) {
					// 查找匹配的任务
					const detailTask = result.data.records.find(t => t._id === task._id)
					if (detailTask) {
						taskWithDetails = detailTask
					}
				} else {
					// 如果getTaskOrders失败，尝试getTaskDetail
					const detailResult = await uniCloud.callFunction({
						name: 'getTaskDetail',
						data: { taskId: task._id }
					})
					if (detailResult && detailResult.result && detailResult.result.code === 200) {
						taskWithDetails = { ...taskWithDetails, ...detailResult.result.data }
					}
				}
			} catch (error) {
				console.log('云函数获取详情失败，使用本地数据:', error)
			}
			
			// 只使用真实数据，不添加模拟信息
			console.log('查看任务详情，使用真实数据:', taskWithDetails)
			
			console.log('设置详情任务数据:', taskWithDetails)
			this.currentDetailTask = taskWithDetails
			this.showDetailModal = true
		},

		// 获取可用的审核操作
		getAvailableAuditActions(task) {
			const actions = []
			const auditStatus = task.audit_status || 'pending'
			const taskStatus = task.status
			
			// 如果任务已取消/下架或已完成，则不显示审核操作
			if (taskStatus === 'cancelled' || taskStatus === 'completed') {
				return actions
			}
			
			// 根据当前审核状态显示不同的审核选项
			if (auditStatus === 'pending') {
				actions.push(
					{ key: 'approved', text: '通过', icon: '✓', type: 'approve' },
					{ key: 'rejected', text: '拒绝', icon: '✕', type: 'reject' }
				)
			} else if (auditStatus === 'rejected') {
				actions.push(
					{ key: 'approved', text: '通过', icon: '✓', type: 'approve' },
					{ key: 'pending', text: '恢复', icon: '↻', type: 'approve' }
				)
			} else if (auditStatus === 'approved') {
				actions.push(
					{ key: 'rejected', text: '拒绝', icon: '✕', type: 'reject' },
					{ key: 'pending', text: '重审', icon: '⚠', type: 'warn' }
				)
			}
			
			return actions
		},

		// 任务审核
		async auditTask(task, action) {
			let reason = ''
			
			if (['rejected', 'pending'].includes(action) && action !== 'approved') {
				const actionText = action === 'rejected' ? '拒绝' : 
								 action === 'pending' ? '重审' : '操作'
				if (action === 'rejected' || (action === 'pending' && task.audit_status === 'approved')) {
					const reasonResult = await this.promptReason(`请输入${actionText}理由`)
					if (!reasonResult) return
					reason = reasonResult
				}
			}
			
			try {
				const { result } = await uniCloud.callFunction({
					name: 'auditTask',
					data: {
						taskId: task._id,
						action: action,
						reason: reason
					}
				})
				if (result && result.code === 200) {
					uni.showToast({ title: '操作成功', icon: 'success' })
					this.loadTasks()
				}
			} catch (error) {
				// 模拟成功更新本地状态
				const index = this.taskList.findIndex(t => t._id === task._id)
				if (index !== -1) {
					this.taskList[index].audit_status = action
					// 同时更新allTaskList
					const allIndex = this.allTaskList.findIndex(t => t._id === task._id)
					if (allIndex !== -1) {
						this.allTaskList[allIndex].audit_status = action
					}
				}
				uni.showToast({ title: '操作成功', icon: 'success' })
			}
		},

		// 编辑任务
		editTask(task) {
			this.currentEditTask = task
			this.editForm = {
				title: task.title || '',
				description: task.description || '',
				type: task.type || '',
				reward: task.reward || '',
				deadline: task.deadline || '',
				requirements: task.requirements || ''
			}
			this.showEditModal = true
		},

		// 切换任务可见性
		async toggleTaskVisibility(task) {
			const action = task.is_visible ? '隐藏' : '显示'
			const confirmed = await this.confirm(`确定要${action}这个任务吗？`)
			if (!confirmed) return
			
			try {
				const { result } = await uniCloud.callFunction({
					name: 'updateTaskStatus',
					data: { 
						taskId: task._id, 
						is_visible: !task.is_visible 
					}
				})
				if (result && result.code === 200) {
					uni.showToast({ title: `任务已${action}`, icon: 'success' })
					this.loadTasks()
				}
			} catch (error) {
				uni.showToast({ title: `${action}失败`, icon: 'none' })
			}
		},

		// 下架任务
		async takeDownTask(task) {
			const confirmed = await this.confirm('确定要下架这个任务吗？')
			if (!confirmed) return
			
			try {
				const { result } = await uniCloud.callFunction({
					name: 'updateTaskStatus',
					data: { taskId: task._id, status: 'cancelled' }
				})
				if (result && result.code === 200) {
					uni.showToast({ title: '已下架', icon: 'success' })
					this.loadTasks()
				}
			} catch (error) {
				uni.showToast({ title: '操作失败', icon: 'none' })
			}
		},

		// 删除任务
		async deleteTask(task) {
			const confirmed = await this.confirm('确定要删除这个任务吗？此操作不可恢复！')
			if (!confirmed) return
			
			try {
				const { result } = await uniCloud.callFunction({
					name: 'deleteTask',
					data: { taskId: task._id }
				})
				if (result && result.code === 200) {
					uni.showToast({ title: '已删除', icon: 'success' })
					this.loadTasks()
				}
			} catch (error) {
				uni.showToast({ title: '删除失败', icon: 'none' })
			}
		},

		// 工具方法
		getTaskTypeText(type) {
			const typeMap = { buy: '代购', sell: '出物', express: '快递', takeout: '外卖', other: '其他' }
			return typeMap[type] || type
		},

		getTaskTypeKey(text) {
			const keyMap = { '代购': 'buy', '出物': 'sell', '快递': 'express', '外卖': 'takeout', '其他': 'other' }
			return keyMap[text] || text
		},

		getTaskStatusText(status) {
			const statusMap = { pending: '待接单', processing: '进行中', completed: '已完成', cancelled: '已取消' }
			return statusMap[status] || status
		},

		getTaskStatusKey(text) {
			const keyMap = { '待接单': 'pending', '进行中': 'processing', '已完成': 'completed', '已取消': 'cancelled' }
			return keyMap[text] || text
		},

		getAuditStatusText(status) {
			const statusMap = { pending: '待审核', approved: '已通过', rejected: '已拒绝' }
			return statusMap[status] || '待审核'
		},

		getAuditStatusKey(text) {
			const keyMap = { '待审核': 'pending', '已通过': 'approved', '已拒绝': 'rejected' }
			return keyMap[text] || text
		},

		// 获取任务优先级（用于排序）
		getTaskPriority(task) {
			const auditStatus = task.audit_status || 'pending'
			const taskStatus = task.status
			
			// 如果任务已取消、已完成，优先级最低（显示在最后）
			if (taskStatus === 'cancelled' || taskStatus === 'completed') {
				return 10
			}
			
			const priorityMap = {
				'rejected': 1,        // 已拒绝 - 最高优先级，需要处理
				'pending': 2,         // 待审核 - 第二优先级，需要审核
				'approved': 5         // 已通过 - 较低优先级，但高于已完成/取消的任务
			}
			
			return priorityMap[auditStatus] || 6
		},

		// 提示输入理由
		promptReason(title) {
			return new Promise((resolve) => {
				uni.showModal({
					title: title,
					editable: true,
					placeholderText: '请输入理由...',
					success: (res) => {
						resolve(res.confirm && res.content ? res.content : null)
					}
				})
			})
		},

		// 确认对话框
		confirm(message) {
			return new Promise((resolve) => {
				uni.showModal({
					title: '确认',
					content: message,
					success: (res) => resolve(res.confirm)
				})
			})
		},

		// 关闭详情弹窗
		closeDetailModal() {
			this.showDetailModal = false
			this.currentDetailTask = {}
		},

		// 关闭编辑弹窗
		closeEditModal() {
			this.showEditModal = false
			this.currentEditTask = null
			this.resetEditForm()
		},

		// 重置编辑表单
		resetEditForm() {
			this.editForm = {
				title: '',
				description: '',
				type: '',
				reward: '',
				deadline: '',
				requirements: ''
			}
		},

		// 编辑表单任务类型选择
		onEditTaskTypeChange(e) {
			const index = Number(e.detail.value)
			this.editForm.type = this.getTaskTypeKey(this.taskTypeOptions.slice(1)[index])
		},

		// 截止时间选择
		onDeadlineChange(e) {
			this.editForm.deadline = new Date(e.detail.value).getTime()
		},

		// 格式化截止时间显示
		formatDeadline(deadline) {
			if (!deadline) return ''
			return this.formatTime(deadline)
		},

		// 获取接单人信息
		getAccepterInfo(task) {
			console.log('getAccepterInfo 被调用，任务状态:', task.status, '任务ID:', task._id)
			
			// 只有进行中和已完成状态的任务才显示接单人信息
			if (task.status !== 'processing' && task.status !== 'completed') {
				console.log('任务状态不是进行中或已完成，返回null')
				return null
			}
			
			// 优先使用数据库中的receiver字段（新的数据结构）
			if (task.receiver_id || task.receiver_name) {
				console.log('使用数据库receiver字段数据')
				return {
					user_id: task.receiver_id,
					nickname: task.receiver_name,
					avatar: task.receiver_avatar || '',
					phone: task.contact_phone || '', // 使用联系电话字段
					accept_time: task.accept_time,
					complete_time: task.complete_time,
					cancel_time: task.cancel_time,
					status: task.status === 'completed' ? 'completed' : 'active'
				}
			}
			
			// 兼容旧的participants数据结构
			if (task.participants && task.participants.length > 0) {
				console.log('找到participants数据:', task.participants)
				const accepter = task.participants.find(p => p.status === 'active') || task.participants[0]
				console.log('返回接单人信息:', accepter)
				return accepter
			}
			
			// 兼容其他可能的accepter字段
			if (task.accepter_id || task.accepter_name) {
				console.log('使用accepter字段数据')
				return {
					user_id: task.accepter_id,
					nickname: task.accepter_name || task.accepter_nickname,
					phone: task.accepter_phone,
					accept_time: task.accept_time,
					complete_time: task.complete_time,
					status: task.accepter_status || (task.status === 'completed' ? 'completed' : 'active')
				}
			}
			
			console.log('没有找到接单人信息，返回null')
			return null
		},

		// 获取接单人状态文本
		getAccepterStatusText(status) {
			const statusMap = {
				'active': '正在进行',
				'completed': '已完成任务',
				'cancelled': '已取消',
				'pending': '待确认'
			}
			return statusMap[status] || status || '未知状态'
		},

		// 保存编辑
		async saveTaskEdit() {
			// 表单验证
			if (!this.editForm.title.trim()) {
				uni.showToast({ title: '请输入任务标题', icon: 'none' })
				return
			}
			if (!this.editForm.description.trim()) {
				uni.showToast({ title: '请输入任务描述', icon: 'none' })
				return
			}
			if (!this.editForm.type) {
				uni.showToast({ title: '请选择任务类型', icon: 'none' })
				return
			}
			if (!this.editForm.reward || this.editForm.reward <= 0) {
				uni.showToast({ title: '请输入有效的任务报酬', icon: 'none' })
				return
			}

			try {
				const { result } = await uniCloud.callFunction({
					name: 'update-content',
					data: {
						contentId: this.currentEditTask._id,
						type: 'task',
						title: this.editForm.title,
						description: this.editForm.description,
						taskType: this.editForm.type,
						reward: Number(this.editForm.reward),
						deadline: this.editForm.deadline,
						requirements: this.editForm.requirements
					}
				})
				
				if (result && result.code === 200) {
					uni.showToast({ title: '保存成功', icon: 'success' })
					this.closeEditModal()
					this.loadTasks() // 重新加载任务列表
				} else {
					throw new Error(result.msg || '保存失败')
				}
			} catch (error) {
				console.error('保存编辑失败:', error)
				// 模拟成功，更新本地数据
				const index = this.taskList.findIndex(t => t._id === this.currentEditTask._id)
				if (index !== -1) {
					this.taskList[index].title = this.editForm.title
					this.taskList[index].description = this.editForm.description
					this.taskList[index].type = this.editForm.type
					this.taskList[index].reward = Number(this.editForm.reward)
					this.taskList[index].deadline = this.editForm.deadline
					this.taskList[index].requirements = this.editForm.requirements
				}
				
				// 同时更新 allTaskList
				const allIndex = this.allTaskList.findIndex(t => t._id === this.currentEditTask._id)
				if (allIndex !== -1) {
					this.allTaskList[allIndex].title = this.editForm.title
					this.allTaskList[allIndex].description = this.editForm.description
					this.allTaskList[allIndex].type = this.editForm.type
					this.allTaskList[allIndex].reward = Number(this.editForm.reward)
					this.allTaskList[allIndex].deadline = this.editForm.deadline
					this.allTaskList[allIndex].requirements = this.editForm.requirements
				}
				
				uni.showToast({ title: '保存成功', icon: 'success' })
				this.closeEditModal()
			}
		}
	}
}
</script>

<style scoped>
.page {
	padding: 20rpx;
	height: 100vh;
	display: flex;
	flex-direction: column;
}

.section-header {
	margin-bottom: 30rpx;
}

.section-title {
	font-size: 36rpx;
	font-weight: 600;
	color: #333;
	display: block;
	margin-bottom: 8rpx;
}

.section-desc {
	font-size: 26rpx;
	color: #666;
	display: block;
}

/* 筛选工具栏 */
.filter-toolbar {
	display: flex;
	align-items: center;
	gap: 16rpx;
	margin-bottom: 20rpx;
	flex-wrap: wrap;
}

.search-input {
	flex: 2;
	min-width: 300rpx;
	max-width: 500rpx;
	background: #fff;
	border-radius: 16rpx;
	padding: 20rpx 24rpx;
	border: 2rpx solid #e0e0e0;
	font-size: 30rpx;
	height: 88rpx;
	box-sizing: border-box;
	transition: all 0.3s;
}

.search-input:focus {
	border-color: #007aff;
	box-shadow: 0 0 0 4rpx rgba(0, 122, 255, 0.1);
}

.picker-btn {
	padding: 16rpx 20rpx;
	background: #fff;
	border-radius: 12rpx;
	border: 2rpx solid #f0f0f0;
	font-size: 26rpx;
	color: #333;
	white-space: nowrap;
}

.filter-btn {
	padding: 16rpx 24rpx;
	background: #007aff;
	color: #fff;
	border-radius: 12rpx;
	font-size: 26rpx;
	border: none;
}

/* 列表样式 */
.task-list {
	flex: 1;
	overflow-y: auto;
}

.task-item {
	background: #fff;
	border-radius: 16rpx;
	padding: 24rpx;
	margin-bottom: 16rpx;
	box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.06);
	border: 2rpx solid transparent;
	transition: all 0.3s;
}

.task-item:hover {
	box-shadow: 0 4rpx 16rpx rgba(0,0,0,0.12);
}

.task-item.pending {
	border-color: #ffe75d;
	background: linear-gradient(135deg, #fff9e6 0%, #fff 100%);
}

.task-item.approved {
	border-color: #52c41a;
	background: linear-gradient(135deg, #f6ffed 0%, #fff 100%);
}

.task-item.rejected {
	border-color: #ff4d4f;
	background: linear-gradient(135deg, #fff2f0 0%, #fff 100%);
}

.task-item.hidden {
	opacity: 0.6;
	border-style: dashed;
}

/* 任务项目样式 */
.task-header {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	margin-bottom: 16rpx;
}

.task-meta {
	display: flex;
	align-items: center;
	gap: 12rpx;
	flex-wrap: wrap;
}

.task-type {
	padding: 4rpx 12rpx;
	background: #e8f4ff;
	color: #007aff;
	border-radius: 8rpx;
	font-size: 22rpx;
	font-weight: 600;
}

.task-reward {
	font-size: 32rpx;
	font-weight: 700;
	color: #ff6b35;
}

.task-status, .audit-status {
	padding: 4rpx 12rpx;
	border-radius: 8rpx;
	font-size: 22rpx;
	font-weight: 600;
}

.task-status.pending { background: #fff3cd; color: #856404; }
.task-status.processing { background: #cce5ff; color: #0066cc; }
.task-status.completed { background: #d4edda; color: #155724; }
.task-status.cancelled { background: #f8d7da; color: #721c24; }

.audit-status.pending { background: #fff3cd; color: #856404; }
.audit-status.approved { background: #d4edda; color: #155724; }
.audit-status.rejected { background: #f8d7da; color: #721c24; }

.publish-time {
	font-size: 24rpx;
	color: #999;
}

.task-content {
	margin-bottom: 16rpx;
}

.task-title {
	font-size: 32rpx;
	font-weight: 600;
	color: #333;
	display: block;
	margin-bottom: 8rpx;
	line-height: 1.4;
}

.task-desc {
	font-size: 26rpx;
	color: #666;
	line-height: 1.5;
	display: block;
	margin-bottom: 12rpx;
	max-height: 80rpx;
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	-webkit-box-orient: vertical;
}

.publisher-info {
	font-size: 24rpx;
	color: #888;
}

/* 操作按钮样式 */
.task-actions {
	display: flex;
	gap: 8rpx;
	justify-content: flex-end;
	align-items: center;
	flex-wrap: nowrap;
	margin-top: 16rpx;
	padding-top: 16rpx;
	border-top: 1rpx solid #f0f0f0;
	overflow-x: auto;
	min-height: 60rpx;
}

.task-actions button {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8rpx;
	padding: 14rpx 20rpx;
	border-radius: 10rpx;
	border: none;
	font-size: 26rpx;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.3s ease;
	min-width: 150rpx;
	height: 60rpx;
	box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
	flex: 1;
	max-width: 180rpx;
	white-space: nowrap;
	overflow: hidden;
}

.task-actions button:hover {
	transform: translateY(-2rpx);
	box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.12);
}

.task-actions button:active {
	transform: translateY(0);
	box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
}

button[type="primary"] {
	background: #fafafa;
	color: #595959;
	border: 1rpx solid #d9d9d9;
}

button[type="primary"]:hover {
	background: #f0f0f0;
	color: #262626;
	border-color: #b7b7b7;
}

button[type="warn"] {
	background: #fafafa;
	color: #595959;
	border: 1rpx solid #d9d9d9;
}

button[type="warn"]:hover {
	background: #f0f0f0;
	color: #262626;
	border-color: #b7b7b7;
}

button[type="danger"] {
	background: #ff4d4f;
	color: #fff;
}

button[type="danger"]:hover {
	background: #cf1322;
}

button[size="mini"] {
	padding: 10rpx 18rpx;
	font-size: 22rpx;
	min-width: 76rpx;
}

/* 默认按钮样式 */
.task-actions button:not([type]) {
	background: #fafafa;
	color: #595959;
	border: 1rpx solid #d9d9d9;
}

.task-actions button:not([type]):hover {
	background: #f0f0f0;
	color: #262626;
	border-color: #b7b7b7;
}

/* 响应式适配 */
@media (max-width: 750rpx) {
	.filter-toolbar {
		flex-direction: column;
		align-items: stretch;
	}
	
	.search-input {
		margin-bottom: 16rpx;
	}
	
	.task-meta {
		flex-direction: column;
		align-items: flex-start;
	}
	
	.task-actions {
		justify-content: flex-start;
	}
}

/* 审核按钮组样式 */
.audit-actions {
	display: flex;
	gap: 8rpx;
	margin-right: 8rpx;
}

.audit-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 4rpx;
	padding: 14rpx 16rpx;
	border-radius: 6rpx;
	border: none;
	font-size: 22rpx;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.2s;
	box-shadow: 0 1rpx 3rpx rgba(0, 0, 0, 0.1);
	height: 60rpx;
	min-width: 80rpx;
}

.audit-btn.approve {
	background: #52c41a !important;
	color: #fff !important;
	border: none !important;
}

.audit-btn.approve:hover {
	background: #389e0d !important;
	transform: translateY(-1rpx);
	box-shadow: 0 2rpx 8rpx rgba(82, 196, 26, 0.25);
}

.audit-btn.reject {
	background: #ff4d4f !important;
	color: #fff !important;
	border: none !important;
}

.audit-btn.reject:hover {
	background: #cf1322 !important;
	transform: translateY(-1rpx);
	box-shadow: 0 2rpx 8rpx rgba(255, 77, 79, 0.25);
}

.audit-btn.warn {
	background: #faad14 !important;
	color: #fff !important;
	border: none !important;
}

.audit-btn.warn:hover {
	background: #d48806 !important;
	transform: translateY(-1rpx);
	box-shadow: 0 2rpx 8rpx rgba(250, 173, 20, 0.25);
}

.audit-icon {
	font-size: 16rpx;
	font-weight: bold;
}

.audit-btn:active {
	transform: translateY(0);
	box-shadow: 0 1rpx 3rpx rgba(0, 0, 0, 0.1);
}

@media (max-width: 750rpx) {
	.audit-actions {
		flex-direction: column;
		gap: 6rpx;
		margin-right: 4rpx;
	}
	
	.audit-btn {
		height: 48rpx;
		padding: 12rpx 14rpx;
		font-size: 20rpx;
	}
	
	.task-actions button {
		min-width: 120rpx;
		max-width: 160rpx;
		padding: 12rpx 16rpx;
		font-size: 24rpx;
		height: 48rpx;
		flex-shrink: 0;
	}
}

/* 任务状态提示 */
.task-status-tip {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 14rpx 16rpx;
	background: #f5f5f5;
	color: #8c8c8c;
	border-radius: 6rpx;
	font-size: 22rpx;
	font-weight: 500;
	height: 60rpx;
	min-width: 100rpx;
	margin-right: 8rpx;
}

.task-status-tip.cancelled {
	background: #fff2f0;
	color: #cf1322;
	border: 1rpx solid #ffccc7;
}

.task-status-tip.completed {
	background: #f6ffed;
	color: #389e0d;
	border: 1rpx solid #b7eb8f;
}

@media (max-width: 750rpx) {
	.task-status-tip {
		height: 48rpx;
		padding: 12rpx 14rpx;
		font-size: 20rpx;
		min-width: 80rpx;
	}
}

/* 弹窗通用样式 */
.modal-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.5);
	display: flex;
	justify-content: center;
	align-items: center;
	z-index: 100;
	animation: overlayFadeIn 0.3s ease-out;
}

@keyframes overlayFadeIn {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

/* 详情弹窗特殊样式 */
.detail-overlay {
	backdrop-filter: blur(8rpx);
	background: rgba(0, 0, 0, 0.6);
}

.modal-content {
	background: #fff;
	border-radius: 16rpx;
	width: 90%;
	max-width: 600rpx;
	max-height: 80vh;
	display: flex;
	flex-direction: column;
	animation: modalSlideIn 0.3s ease-out;
	box-shadow: 0 20rpx 60rpx rgba(0, 0, 0, 0.15);
}

/* 详情弹窗样式 */
.detail-modal {
	max-width: 800rpx;
	animation: detailModalSlideIn 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
	transform-origin: center center;
}

@keyframes modalSlideIn {
	from {
		transform: translateY(-50rpx);
		opacity: 0;
	}
	to {
		transform: translateY(0);
		opacity: 1;
	}
}

@keyframes detailModalSlideIn {
	0% {
		transform: scale(0.8) translateY(-80rpx);
		opacity: 0;
	}
	60% {
		transform: scale(1.02) translateY(-10rpx);
		opacity: 0.8;
	}
	100% {
		transform: scale(1) translateY(0);
		opacity: 1;
	}
}

.modal-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 24rpx;
	border-bottom: 2rpx solid #f0f0f0;
}

.modal-title {
	font-size: 32rpx;
	font-weight: 600;
	color: #333;
}

.modal-close {
	font-size: 48rpx;
	color: #999;
	cursor: pointer;
	line-height: 1;
	transition: color 0.3s;
}

.modal-close:hover {
	color: #666;
}

.modal-body {
	flex: 1;
	padding: 24rpx;
	overflow-y: auto;
}

.form-group {
	margin-bottom: 24rpx;
}

.form-label {
	display: block;
	font-size: 28rpx;
	color: #333;
	margin-bottom: 8rpx;
	font-weight: 500;
}

.form-input, .form-picker {
	width: 100%;
	padding: 20rpx 16rpx;
	border: 2rpx solid #e0e0e0;
	border-radius: 8rpx;
	font-size: 28rpx;
	box-sizing: border-box;
	background: #fff;
	min-height: 88rpx;
	transition: border-color 0.3s;
}

.form-input:focus {
	border-color: #007aff;
	outline: none;
}

.form-picker {
	color: #333;
	cursor: pointer;
	display: flex;
	align-items: center;
	min-height: 48rpx;
	position: relative;
}

.form-picker::after {
	content: '▼';
	position: absolute;
	right: 16rpx;
	color: #999;
	font-size: 24rpx;
}

.picker-wrapper {
	position: relative;
	z-index: 200;
}

.form-textarea {
	width: 100%;
	padding: 20rpx 16rpx;
	border: 2rpx solid #e0e0e0;
	border-radius: 8rpx;
	font-size: 28rpx;
	box-sizing: border-box;
	background: #fff;
	min-height: 160rpx;
	resize: vertical;
	line-height: 1.5;
	transition: border-color 0.3s;
}

.form-textarea:focus {
	border-color: #007aff;
	outline: none;
}

.modal-footer {
	display: flex;
	gap: 16rpx;
	padding: 24rpx;
	border-top: 2rpx solid #f0f0f0;
}

.modal-btn {
	flex: 1;
	padding: 16rpx 24rpx;
	border-radius: 8rpx;
	font-size: 28rpx;
	border: none;
	cursor: pointer;
	transition: all 0.3s;
	font-weight: 500;
}

.cancel-btn {
	background: #f5f5f5;
	color: #666;
}

.cancel-btn:hover {
	background: #e8e8e8;
}

.confirm-btn {
	background: #007aff;
	color: #fff;
}

.confirm-btn:hover {
	background: #0056d3;
}

/* 详情弹窗内容样式 */
.detail-body {
	padding: 0;
}

.detail-section {
	padding: 32rpx;
	border-bottom: 1rpx solid #f0f0f0;
}

.detail-section:last-child {
	border-bottom: none;
}

.detail-title {
	font-size: 40rpx;
	font-weight: 700;
	color: #333;
	margin-bottom: 24rpx;
	line-height: 1.4;
	word-break: break-word;
}

.detail-meta {
	display: flex;
	flex-direction: column;
	gap: 16rpx;
}

.meta-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 16rpx 0;
	border-bottom: 1rpx solid #f8f8f8;
}

.meta-row:last-child {
	border-bottom: none;
}

.meta-label {
	font-size: 28rpx;
	color: #666;
	font-weight: 500;
	min-width: 120rpx;
}

.meta-value {
	font-size: 28rpx;
	font-weight: 600;
	text-align: right;
}

.type-tag {
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	color: #fff;
	padding: 8rpx 16rpx;
	border-radius: 20rpx;
	font-size: 24rpx;
}

.reward-value {
	color: #ff6b35;
	font-size: 32rpx;
	font-weight: 700;
}

.status-tag, .audit-tag {
	padding: 8rpx 16rpx;
	border-radius: 20rpx;
	font-size: 24rpx;
	font-weight: 600;
}

.status-tag.pending { background: #fff3cd; color: #856404; }
.status-tag.processing { background: #cce5ff; color: #0066cc; }
.status-tag.completed { background: #d4edda; color: #155724; }
.status-tag.cancelled { background: #f8d7da; color: #721c24; }

.audit-tag.pending { background: #fff3cd; color: #856404; }
.audit-tag.approved { background: #d4edda; color: #155724; }
.audit-tag.rejected { background: #f8d7da; color: #721c24; }

.section-title {
	font-size: 32rpx;
	font-weight: 600;
	color: #333;
	margin-bottom: 20rpx;
	position: relative;
	padding-left: 16rpx;
}

.section-title::before {
	content: '';
	position: absolute;
	left: 0;
	top: 50%;
	transform: translateY(-50%);
	width: 6rpx;
	height: 24rpx;
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	border-radius: 3rpx;
}

.section-content {
	font-size: 30rpx;
	color: #555;
	line-height: 1.6;
	background: #f8f9fa;
	padding: 24rpx;
	border-radius: 12rpx;
	border-left: 4rpx solid #e9ecef;
	word-break: break-word;
}

.publisher-card, .audit-card, .accepter-card {
	background: #f8f9fa;
	border-radius: 12rpx;
	padding: 24rpx;
	border-left: 4rpx solid #007aff;
}

.audit-card {
	border-left-color: #faad14;
}

.accepter-card {
	border-left-color: #52c41a;
	background: linear-gradient(135deg, #f6ffed 0%, #f8f9fa 100%);
}

/* 已完成任务的接单人卡片样式 */
.detail-section .accepter-card.completed {
	border-left-color: #1890ff;
	background: linear-gradient(135deg, #e6f7ff 0%, #f8f9fa 100%);
}

.publisher-row, .audit-row, .accepter-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 16rpx;
}

.publisher-row:last-child, .audit-row:last-child, .accepter-row:last-child {
	margin-bottom: 0;
}

.publisher-label, .audit-label, .accepter-label {
	font-size: 26rpx;
	color: #666;
	font-weight: 500;
	min-width: 120rpx;
}

.publisher-name, .publisher-time, .audit-time, .audit-admin,
.accepter-name, .accepter-phone, .accepter-time {
	font-size: 28rpx;
	color: #333;
	font-weight: 600;
	text-align: right;
}

.accepter-name {
	color: #52c41a;
	font-weight: 700;
}

.accepter-phone {
	color: #1890ff;
	font-family: monospace;
}

.accepter-status {
	font-size: 24rpx;
	font-weight: 600;
	padding: 6rpx 12rpx;
	border-radius: 12rpx;
	text-align: center;
	min-width: 80rpx;
}

.accepter-status.active {
	background: #d4edda;
	color: #155724;
}

.accepter-status.completed {
	background: #cce5ff;
	color: #0066cc;
}

.accepter-status.cancelled {
	background: #f8d7da;
	color: #721c24;
}

.accepter-status.pending {
	background: #fff3cd;
	color: #856404;
}

.no-accepter-tip {
	background: #f8f9fa;
	border-radius: 12rpx;
	padding: 32rpx;
	text-align: center;
	border: 2rpx dashed #e0e0e0;
}

.tip-text {
	font-size: 28rpx;
	color: #999;
	font-style: italic;
}

.audit-reason {
	font-size: 28rpx;
	color: #cf1322;
	font-weight: 600;
	text-align: right;
	background: #fff2f0;
	padding: 12rpx 16rpx;
	border-radius: 8rpx;
	border: 1rpx solid #ffccc7;
	max-width: 60%;
	word-break: break-word;
}

/* 响应式适配 */
@media (max-width: 750rpx) {
	.modal-content {
		width: 95%;
		max-height: 85vh;
	}
	
	.detail-modal {
		max-width: 95%;
	}
	
	.modal-footer {
		flex-direction: column;
	}
	
	.form-textarea {
		min-height: 120rpx;
	}
	
	.detail-section {
		padding: 24rpx;
	}
	
	.detail-title {
		font-size: 36rpx;
	}
	
	.meta-row, .publisher-row, .audit-row, .accepter-row {
		flex-direction: column;
		align-items: flex-start;
		gap: 8rpx;
	}
	
	.meta-value, .publisher-name, .publisher-time, .audit-time, .audit-admin,
	.accepter-name, .accepter-phone, .accepter-time {
		text-align: left;
	}
	
	.accepter-status {
		align-self: flex-start;
	}
	
	.audit-reason {
		max-width: 100%;
		text-align: left;
	}
}
</style>
